Skip to content

Subnet Protocol Alpha Accounting#2645

Open
JohnReedV wants to merge 9 commits into
devnet-readyfrom
chain-buy-cache
Open

Subnet Protocol Alpha Accounting#2645
JohnReedV wants to merge 9 commits into
devnet-readyfrom
chain-buy-cache

Conversation

@JohnReedV
Copy link
Copy Markdown
Contributor

Description

This PR adds protocol-owned alpha accounting for subnet chain buys and includes that alpha in subnet deregistration settlement.

  • Stops recycling alpha bought during protocol TAO buys
  • Adds per-subnet cached protocol alpha accounting
  • Includes protocol alpha-in and cached protocol alpha in deregistration pro-rata settlement
  • Clears cached protocol alpha when a subnet is dissolved
  • Updates tests for the new deregistration settlement behavior

@JohnReedV JohnReedV added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label May 7, 2026
Comment thread pallets/subtensor/src/coinbase/run_coinbase.rs
@github-actions github-actions Bot mentioned this pull request May 21, 2026
4 tasks
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🛡️ AI Review — Skeptic (security review)

VERDICT: SAFE

Baseline scrutiny: established opentensor contributor with repo write permission; branch chain-buy-cache -> devnet-ready; no trusted gittensor allowlist hit.

Static review only. The PR does not modify .github/, dependency manifests, lockfiles, or build scripts. The runtime-facing changes add protocol-owned alpha accounting for chain buys and include that accounting in subnet dissolve settlement, using saturating/checked arithmetic and clearing the new per-subnet storage on dissolution.

Findings

No findings.

Conclusion

No malicious behavior or security vulnerability was found in the reviewed diff. The remaining risk is ordinary runtime-economic correctness risk around the new settlement accounting, which is covered by the Auditor persona rather than a Skeptic finding.


🔍 AI Review — Auditor (domain review)

VERDICT: 👍

Established opentensor contributor with repo write permission; no trusted Gittensor allowlist hit, but long prior subtensor contribution history supports established-contributor calibration.

PR body is substantive and matches the implementation. I did not find a duplicate-work concern among the overlapping open PRs; the overlaps appear to be adjacent subtensor/runtime churn rather than competing implementations.

Targeted runtime tests were attempted for the new dissolve/coinbase cases, but the sandboxed toolchain could not run because rustup failed to create temp files under read-only /home/runner/.rustup. Spec-version auto-fix was not performed because the devnet RPC host could not be resolved from this sandbox; local spec_version remains unchanged from base at 409, so the authoritative CI check should handle whether a bump is required.

Findings

Sev File Finding
MEDIUM pallets/subtensor/src/staking/remove_stake.rs:478 Update dissolve weights for protocol-alpha storage inline

Conclusion

The accounting change is directionally consistent with the PR description and has focused tests. The only issue I found is a small but real weight-accounting gap for the added dissolve storage access; it should be fixed before or during merge hardening but does not by itself block this PR.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment on lines +476 to +478
let protocol_alpha_value_u128: u128 = SubnetAlphaIn::<T>::get(netuid)
.saturating_add(SubnetProtocolAlpha::<T>::get(netuid))
.to_u64() as u128;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Update dissolve weights for protocol-alpha storage

This adds a new SubnetProtocolAlpha read to the dissolve path, and the same function now also removes that map later in the cleanup. The dispatch weights for both dissolve_network and root_dissolve_network in pallets/subtensor/src/macros/dispatches.rs still charge the old reads(6) / writes(31), so the runtime undercharges this path by at least the new protocol-alpha read/write. Please update those annotations or regenerate the relevant weight so the storage proof and DB ops match the new dissolve accounting.

@github-actions
Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants